package com.tich.program.controller;


import cn.hutool.core.bean.BeanUtil;
import com.tich.constant.ResponseMessageConstant;
import com.tich.program.domain.dto.TicketCategoryDeleteDTO;
import com.tich.program.domain.dto.TicketCategorySaveDTO;
import com.tich.program.domain.dto.TicketCategorySelectDTO;
import com.tich.program.domain.entity.TicketCategory;
import com.tich.program.domain.vo.TicketCategoryVO;
import com.tich.program.service.ITicketCategoryService;
import com.tich.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * 门票种类接口
 */
@Slf4j
@RestController
@RequestMapping("/ticket/category")
public class TicketCategoryController {

    @Autowired
    private ITicketCategoryService iTicketCategoryService;

    /**
     * 根据节目类型id集合批量查询门票类型
     * @param ticketCategorySelectDTO
     * @return
     * */
    @PostMapping("/selectByIdList")
    public Result<List<TicketCategoryVO>> queryTicketCategoryByIds(@RequestBody TicketCategorySelectDTO ticketCategorySelectDTO){
        log.info("查询所有门票种类");
        return Result.success(ResponseMessageConstant.QUERY_SUCCESS,
                iTicketCategoryService.queryTicketCategoryByIds(ticketCategorySelectDTO));
    }

    /**
     * 新增门票类型
     * @param ticketCategorySaveDTO
     * @return
     * */
    @PostMapping("/save")
    public Result saveTicketCategory(@RequestBody TicketCategorySaveDTO ticketCategorySaveDTO){
        log.info("新增门票类型:{}", ticketCategorySaveDTO);
        iTicketCategoryService.save(BeanUtil.copyProperties(ticketCategorySaveDTO, TicketCategory.class));
        return Result.success(ResponseMessageConstant.SAVE_SUCCESS);
    }

    /**
     * 根据ids批量删除门票类型
     * @param ticketCategoryDeleteDTO
     * @return
     * */
    @DeleteMapping
    public Result deleteTicketCategorys(@RequestBody TicketCategoryDeleteDTO ticketCategoryDeleteDTO){
        log.info("根据ids删除门票类型");
        iTicketCategoryService.deleteTicketCategorys(ticketCategoryDeleteDTO);
        return Result.success(ResponseMessageConstant.DELETE_SUCCESS);
    }

}
